package com.gupao.gupaoeduvippattern.pattern.observer.gper;

import java.util.Observable;

/**
 * 被观察者对象---社区空间
 * 单例的
 *
 * @author 大帅
 * @description
 * @date 2020-12-02
 */
public class GPer extends Observable {

    private String name = "GPer生态圈";

    private static final GPer gper = new GPer();

    private GPer() {

    }

    public static GPer getInstance(){
        return gper;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    /**
     * 社区的行为
     * @param question
     */
    public void publishQuestion(Question question){
        System.out.println(question.getUserName()+"在"+this.name+"发布了一个问题，问题内容为："+question.getContent());
        //设置有数据信息改动
        setChanged();
        //通知所有的观察者对象，推送改变的消息
        notifyObservers(question);
    }


}
